package cn.ainit.sys.query;

import java.util.List;

import javax.activation.DataSource;
import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.ainit.sys.ds.store.sysDataStore;
import cn.ainit.sys.query.datastore.DataStore;
import cn.ainit.sys.query.entity.QueryButton;
import cn.ainit.sys.query.entity.QueryColumn;
import cn.ainit.sys.ui.forms.Columns;

@Service
public class DynamicQueryServiceImpl implements DynamicQueryService{
	
	DynamicQueryDao dynamicQueryDao;
	
	@Resource
	public void setDynamicQueryDao(DynamicQueryDao dynamicQueryDao) {
		this.dynamicQueryDao = dynamicQueryDao;
	}
	
	@Override
	public List<QueryButton> getQueryButtons(String partOrAll,String id) throws Exception {
		return dynamicQueryDao.getQueryButtons(partOrAll,id);
	}
	
	@Override
	public List<QueryColumn> getQueryColumns(String partOrAll,String id) throws Exception {
		return dynamicQueryDao.getQueryColumns(partOrAll,id);
	}
	
	@Override
	public List<QueryColumn> getQueryShowColumns(String flag,String id)
			throws Exception {
		return dynamicQueryDao.getQueryShowColumns(flag,id);
	}

	@Override
	public boolean addDataStore(sysDataStore dataStore) throws Exception {
		try {
			dynamicQueryDao.adddataStore(dataStore);
			return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	
	
	@Override
	public List<Columns> getQueryUIColumns(String partOrAll,String formId) throws Exception {
		return  dynamicQueryDao.getQueryUIColumns(partOrAll,formId);
	}

	@Override
	public DataStore querySql(String id) throws Exception {
		return dynamicQueryDao.querySql(id);
	}
	
	@Override
	public List getRows(String sql, int pageNumber, int pageSize)
			throws Exception {
		return dynamicQueryDao.getRows(sql,pageNumber,pageSize);
	}
}
